/* ****************************************************************************
 *
 * Copyright (c) Microsoft Corporation. 
 *
 * This source code is subject to terms and conditions of the Microsoft Public License. A 
 * copy of the license can be found in the License.html file at the root of this distribution. If 
 * you cannot locate the  Microsoft Public License, please send an email to 
 * dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound 
 * by the terms of the Microsoft Public License.
 *
 * You must not remove this notice, or any other, from this software.
 *
 * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
 * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
 * PARTICULAR PURPOSE.
 * ***************************************************************************/




#if !defined(AFX_PGLSTACKEDLINE2D_H__8E5491FE_5390_4697_8295_D28716C94C8F__INCLUDED_)
#define AFX_PGLSTACKEDLINE2D_H__8E5491FE_5390_4697_8295_D28716C94C8F__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <pgl/core/PGLObject.h>
#include <pgl/core/PGLLine1D.h>
#include <pgl/core/PGLLegend.h>
#include <pgl/core/PGLDataVectors.h>

/*! \brief Stacked lines

  \ingroup PGLLineGroup
*/
class PGLCORE_EXT_CLASS CPGLStackedLine2D : public CPGLObject  
{
PGL_DECLARE_DYNCREATE(CPGLStackedLine2D);
public:
	//!\name Constructors
	//@{
	//! Default constructor
	CPGLStackedLine2D(const CPGLColor& _color=CPGLColor());
	//! Copy constructor
	CPGLStackedLine2D(const CPGLStackedLine2D& r): m_pYSum(new CPGLVectorF){*this=r;};
	//! assignment constructor
	CPGLStackedLine2D& operator = (const CPGLStackedLine2D& r);
	//! Destructor
	virtual ~CPGLStackedLine2D() {	Clear();};
	//@}

	//! returns number of x values
	size_t GetDataSize() const			{	return m_pX->size();};
	//! x coordinates
	void SetX(CPGLDataPtr pX);
	//! x coordinates
	void SetX(const std::vector<double>& vX);
	//! x coordinates
	void SetX(const std::vector<float>& vX);
	//! returns the data object
	CPGLDataPtr GetX()					{	return m_pX;};

	//! \name Line container
	//@{
	size_t GetLineSize() const															{	return m_lLines.size();};
	void PushBottom(CPGLLine1DPtr pLine1D);
	void PushTop(CPGLLine1DPtr pLine1D);
	void PushLinesTop(CPGLLegendPtr pLegend);
	CPGLLine1DList::iterator GetBegin()															{	return m_lLines.begin();};
	CPGLLine1DList::const_iterator GetBegin() const												{	return m_lLines.begin();};
	CPGLLine1DList::iterator GetEnd()															{	return m_lLines.end();};
	CPGLLine1DList::const_iterator GetEnd() const												{	return m_lLines.end();};
	CPGLLine1DList::iterator InsertUnder(CPGLLine1DList::iterator il, CPGLLine1DPtr pLine1D)	{	return m_lLines.insert(il,pLine1D);};
	CPGLLine1DList::iterator Erase(CPGLLine1DList::iterator il)									{	if (*il) il->reset(); return m_lLines.erase(il);};
	//@}

	//! \name Cleaning
	//@{
	void Clear();
	//@}

    //! returns the extent of the datas
    virtual void GetUnionExtent(gfxinterface::CGfxInterface& gfx, CPGLRectD& rExtent);
    ///virtual function to override in derived classes
    virtual void UpdateExtent(gfxinterface::CGfxInterface& gfx);
	// plot function
	virtual void PlotGfx(gfxinterface::CGfxInterface& gfx);

//	virtual CPGLObject* FindObjectID(UINT _ID);
	DWORD ProcessType(DWORD eLineType);

	//! Serialize functions
	void SerializeXML(CPGLArchive& ar);

	//! Debuggin functions
	#ifdef _DEBUG
	    virtual void Dump( CDumpContext& dc ) const;
	    virtual void AssertValid() const;   
	#endif

protected:
	CPGLLine1DList m_lLines;
	CPGLDataPtr m_pX;
private:
	CPGLVectorFPtr m_pYSum;
};

PGL_DECLARE_SMARTPTR( CPGLStackedLine2D );

#endif // !defined(AFX_PGLSTACKEDLINE2D_H__8E5491FE_5390_4697_8295_D28716C94C8F__INCLUDED_)
